<?php
class Auth extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		// autoload helper and library
		$this->layout->setLayout('admin');
		$this->load->model('user_model');
	}
	function login()
	{
		$this->layout->view('login');
	}
	function checklogin()
	{
		$username = $this->input->post('txtUserName');
		$password = $this->input->post('txtPassword');
		$user = $this->user_model->checklogin($username,$password);
		if($user != NULL){
			$this->session->set_userdata('auth',$user);
		}
		redirect('admin/');
	}
	function destroys()
	{
		if($this->session->userdata('auth'))
		{
			$this->session->unset_userdata('auth');
			redirect('admin');
		}
	}
}